{% load static %}
<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8">
    <title>更新认证</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href={% static "css/font.css" %}>
    <link rel="stylesheet" href={% static "css/xadmin.css" %}>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src={% static "lib/layui/layui.js" %} charset="utf-8"></script>
    <script type="text/javascript" src={% static "js/xadmin.js" %}></script>


</head>

<body>


<form class="layui-form layui-form-pane">
{% csrf_token %}
    <div class="layui-form-item">
        <label class="layui-form-label">域名</label>
        <div class="layui-input-inline">
            <input type="text" name="domain" placeholder="不填默认全部数据包" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">更新类型</label>
        <div class="layui-input-block">
            <select name="type" lay-filter="type">
                <option value="" selected=""></option>
                <option value="cookie">cookie</option>
                <option value="token">token</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">参数</label>
        <div class="layui-input-inline">
            <input type="text" name="parm" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">更新内容</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="content" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
    </div>

</form>


<script>
    layui.use(['form'], function () {
        var form = layui.form;


        form.on('submit(submit)', function (data) {

            $.ajax({
                type: 'POST',
                url: "{% url "update_auth" %}",
                async: true,
                data: {
                    type: data.field.type,
                    parm: data.field.parm,
                    domain: data.field.domain,
                    content: data.field.content,
                    csrfmiddlewaretoken:data.field.csrfmiddlewaretoken


                },
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 5});//失败的表情
                        return;
                    } else if (data.code == 200) {
                        layer.msg(data.msg, {
                            icon: 6,//成功的表情
                            time: 4000 //1秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭   
							//location.reload();
                        });
                    }
                },
                complete: function () {
                    layer.close(this.layerIndex);
                },
				
            });
            return false;
        });

    });
</script>

</body>
</html>